//  Grunt 的入口文件

const sass = require('sass');

const loadGruntTasks = require('load-grunt-tasks');

module.exports = grunt => {
    grunt.initConfig({
        sass: {
            options: {
                sourceMap: true,
                implementation: sass
            },
            main: {
                files: {
                    'dist/main.css': 'src/main.scss'
                }
            }
        },
        babel: {
            options: {
                sourceMap: true,
                presets: ['@babel/preset-env']
            },
            main: {
                files: {
                    'dist/app.js': 'src/app.js'
                }
            }
        },
        watch: {
            js: {
                files: 'src/*.js',
                tasks: ['babel']
            },
            sass: {
                files: 'src/*.scss',
                tasks: ['sass']
            }
        }
    });


    // grunt.loadNpmTasks('grunt-sass');
    loadGruntTasks(grunt); // 自动加载所有的grunt插件中的任务

    grunt.registerTask('default', ['sass', 'babel', 'watch']);
}